import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2024-02-13
 * Time:9:10
 */
public class Test {
    public static void main(String[] args) {
/*
        String[] words = {"i","love","leetcode","i","love","coding"};
        System.out.println(Solution.topKFrequent(words, 2));
*/
/*
        ListNode node1 = new ListNode(1);
        ListNode node2 = new ListNode(2);
        ListNode node3 = new ListNode(3);
        ListNode node4 = new ListNode(4);
        ListNode node5 = new ListNode(5);
        node1.next = node2;
        node3.next = node4;
        node5 = node4.next;
        Solution.addTwoNumbers(node1,node3);
*/

        Set<String> colors = new HashSet<>();
        colors.add("red");
        colors.add("blue");
        colors.add("green");

        // 使用toArray方法将Set转换为数组
        Object[] colorsArray = colors.toArray();
        System.out.println("Set转换为数组：" + Arrays.toString(colorsArray));

        // 使用重载的toArray方法指定类型
        String[] colorsArray2 = colors.toArray(new String[colors.size()]);
        System.out.println("Set转换为指定类型的数组：" + Arrays.toString(colorsArray2));

    }
}
